<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>小黑博客</title><meta name="author" content="BluesYoung-web"><meta name="copyright" content="BluesYoung-web"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta property="og:type" content="website">
<meta property="og:title" content="小黑博客">
<meta property="og:url" content="https://bluesyoung-web.gitee.io/blog/page/12/index.html">
<meta property="og:site_name" content="小黑博客">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://bluesyoung-web.gitee.io/blog/img/lufei_siwangningshi.jpg">
<meta property="article:author" content="BluesYoung-web">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://bluesyoung-web.gitee.io/blog/img/lufei_siwangningshi.jpg"><link rel="shortcut icon" href="/blog/img/favicon.png"><link rel="canonical" href="https://bluesyoung-web.gitee.io/blog/page/12/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/blog/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: BluesYoung-web","link":"链接: ","source":"来源: 小黑博客","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-right"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '小黑博客',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2021-08-29 19:40:09'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/blog/css/background.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/HexoStaticFile@latest/Hexo/css/custom.min.css"></link><meta name="generator" content="Hexo 5.4.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/blog/img/lufei_siwangningshi.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">153</div></a></div><div class="data-item"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">54</div></a></div><div class="data-item"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">48</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">小黑博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">小黑博客</h1><div id="site-subtitle"><span id="subtitle"></span></div><div id="site_social_icons"><a class="social-icon" href="https://github.com/BluesYoung-web" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:15171255945@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left_radius"><a href="/blog/2020-12-28-14-Date.html" title="14-Date">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="14-Date"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-14-Date.html" title="14-Date">14-Date</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T09:27:33.000Z" title="发表于 2020-12-28 17:27:33">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC05%E7%AB%A0%E2%80%94%E2%80%94%E5%9F%BA%E6%9C%AC%E5%BC%95%E7%94%A8%E7%B1%BB%E5%9E%8B/">第05章——基本引用类型</a></span></div><div class="content">
将日期保存为自协调世界时（UTC，Universal Time Coordinated）时间 1970 年 1 月 1 日午夜（零时）至今所经过的毫秒数
可以精确表示 1970 年 1 月 1 日之前及之后 285 616 年的日期

new Date(any)
不传任何参数，返回保存当前日期和时间的对象(Fri Nov 20 2020 14:03:10 GMT+0800 (中国标准时间))
要基于其他日期和时间创建日期对象，必须传入其毫秒表示(时间戳)
如果传入字符串，则会在后台自动调用Date.parse()
如果传入数值，则会在后台自动调用Date.UTC()，此时创建的为本地时间，不会有 8 小时的时间差

Date.parse(str)
接收一个表示日期的字符串参数，尝试将其转换为对应的时间戳(13位)
支持的日期格式：
“月/日/年”，如&quot;5/23/2019&quot;
“月名 日, 年”，如&quot;May 23, 2019&quot;
“周几 月名 日 年 时:分:秒 时区”，如&quot;Tue May 23 2019 00:00:00 GMT+0800 ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/blog/2020-12-28-13-%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6.html" title="13-垃圾回收">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="13-垃圾回收"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-13-%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6.html" title="13-垃圾回收">13-垃圾回收</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T09:25:43.000Z" title="发表于 2020-12-28 17:25:43">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC04%E7%AB%A0%E2%80%94%E2%80%94%E5%8F%98%E9%87%8F%E3%80%81%E4%BD%9C%E7%94%A8%E5%9F%9F%E4%B8%8E%E5%86%85%E5%AD%98/">第04章——变量、作用域与内存</a></span></div><div class="content">
JavaScript 是使用垃圾回收的语言，也就是说执行环境负责在代码执行时管理内存

基本思路：

确定哪个变量不会再使用，然后释放它占用的内存


这个过程是周期性的，即垃圾回收程序每隔一定时间（或者说在代码执 行过程中某个预定的收集时间）就会自动运行

垃圾回收过程是一个近似且不完美的方案，因为某块内存是否还有用，属于“不可判定的”问题，意味着靠算法是解决不了的

我们以函数中局部变量的正常生命周期为例。函数中的局部变量会在函数执行时存在。此时，栈（或 堆）内存会分配空间以保存相应的值。函数在内部使用了变量，然后退出。此时，就不再需要那个局部 变量了，它占用的内存可以释放，供后面使用。这种情况下显然不再需要局部变量了，但并不是所有时候都会这么明显。垃圾回收程序必须跟踪记录哪个变量还会使用，以及哪个变量不会再使用，以便回收 内存。如何标记未使用的变量也许有不同的实现方式。不过，在浏览器的发展史上，用到过两种主要的标记策略：标记清理和引用计数


标记清理
当变量进入上下文，比如在函数内部声明一个变量时，这个变量会被加上存在于上下文中的标记
而在上下文中的变量，逻辑上讲，永远不应该 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/blog/2020-12-28-12-%E6%89%A7%E8%A1%8C%E4%B8%8A%E4%B8%8B%E6%96%87%E4%B8%8E%E4%BD%9C%E7%94%A8%E5%9F%9F.html" title="12-执行上下文与作用域">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="12-执行上下文与作用域"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-12-%E6%89%A7%E8%A1%8C%E4%B8%8A%E4%B8%8B%E6%96%87%E4%B8%8E%E4%BD%9C%E7%94%A8%E5%9F%9F.html" title="12-执行上下文与作用域">12-执行上下文与作用域</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T09:24:46.000Z" title="发表于 2020-12-28 17:24:46">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC04%E7%AB%A0%E2%80%94%E2%80%94%E5%8F%98%E9%87%8F%E3%80%81%E4%BD%9C%E7%94%A8%E5%9F%9F%E4%B8%8E%E5%86%85%E5%AD%98/">第04章——变量、作用域与内存</a></span></div><div class="content">执行上下文
变量和函数的上下文决定了它们可以访问哪些数据，以及它们的行为
每个上下文都有一个关联的变量对象，而这个上下文中定义的所有变量和函数都存在于这个对象上
全局上下文是最外层的上下文。根据 ECMAScript 实现的宿主环境，表示全局上下文的对象可能不一 样
在浏览器中，全局上下文就是我们常说的 window 对象，因此所有通过 var 定 义的全局变量和函数都会成为 window 对象的属性和方法
使用 let 和 const 的顶级声明不会定义在全局上下文中，但在作用域链解析上效果是一样的
每个函数调用都有自己的上下文。当代码执行流进入函数时，函数的上下文被推到一个上下文栈上。 在函数执行完之后，上下文栈会弹出该函数上下文，将控制权返还给之前的执行上下文
ECMAScript 程序的执行流就是通过这个上下文栈进行控制的

作用域链
上下文中的代码在执行的时候，会创建变量对象的一个作用域链（scope chain）
这个作用域链决定 了各级上下文中的代码在访问变量和函数时的顺序
代码正在执行的上下文的变量对象始终位于作用域链的最前端
如果上下文是函数，则其活动对象（activ ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/blog/2020-12-28-11-%E5%8E%9F%E5%A7%8B%E5%80%BC%E4%B8%8E%E5%BC%95%E7%94%A8%E5%80%BC.html" title="11-原始值与引用值">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="11-原始值与引用值"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-11-%E5%8E%9F%E5%A7%8B%E5%80%BC%E4%B8%8E%E5%BC%95%E7%94%A8%E5%80%BC.html" title="11-原始值与引用值">11-原始值与引用值</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T09:23:45.000Z" title="发表于 2020-12-28 17:23:45">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC04%E7%AB%A0%E2%80%94%E2%80%94%E5%8F%98%E9%87%8F%E3%80%81%E4%BD%9C%E7%94%A8%E5%9F%9F%E4%B8%8E%E5%86%85%E5%AD%98/">第04章——变量、作用域与内存</a></span></div><div class="content">原始值
简单类型的数据
赋值时直接复制值

引用值
复杂数据类型(由多个值构成的对象)
赋值时引用赋值，共享同一内存

动态属性
原始值不能拥有属性
给原始值添加属性不会报错，但是后面也不能获取到该属性
原始类型的初始化只能使用字面量，如果使用 new 关键字则会创建 Object 类型的实例(拥有动态属性，引用赋值，挂载动态属性会影响原始对象)
引用值可以随时添加、修改和删除其属性和方法

复制值
除了存储方式不同，原始值和引用值在通过变量复制时也有所不同
在通过变量把一个原始值赋值 到另一个变量时，原始值会被复制到新变量的位置
这两个变量可以独立使用，互不干扰
把引用值从一个变量赋给另一个变量时，存储在变量中的值也会被复制到新变量所在的位置
区别在于，这里复制的值实际上是一个指针，它指向存储在堆内存中的对象
操作完成后，两个变量实际上指向同一个对象，因此一个对象上面的变化会在另一个对象上反映出来

传递参数
变量作为函数参数被传递时，相当于使用 = 直接赋值
原始值复制赋值
引用值引用赋值

确定类型
typeof 只能检测简单类型的数据
instanceof 通过引用值的原型链判 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/blog/2020-12-28-10-%E5%87%BD%E6%95%B0.html" title="10-函数">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="10-函数"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-10-%E5%87%BD%E6%95%B0.html" title="10-函数">10-函数</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T09:21:20.000Z" title="发表于 2020-12-28 17:21:20">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC03%E7%AB%A0%E2%80%94%E2%80%94%E8%AF%AD%E8%A8%80%E5%9F%BA%E7%A1%80/">第03章——语言基础</a></span></div><div class="content">基础
函数对于任何语言来说都是核心组件
它可以封装语句，然后在任何地方、任何时间执行
使用 return 关键字返回值，return 之后的代码不会执行
函数名就是指向函数对象的指针，而且不一定与函数本身紧密绑定
函数要么返回值，要么不返回值。只在某个条件下返回值的函数会带来麻烦，尤其是调试时
不存在重载，后定义的会覆盖先定义的

1234function fn (a) &#123;  consloe.log(a);  return ++a;&#125;

函数定义方式函数声明
存在提升

123function sum(num1, num2) &#123;  return num1 + num2;&#125;

函数表达式
不存在提升

123const sum = function(num1, num2) &#123;  return num1 + num2;&#125;;

使用构造函数
接受任意多个字符串，最后一个参数会被当成函数体
不存在提升
影响性能，不推荐使用

1const sum = new Function(&#x27;num1&#x27;, &#x27;num2& ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/blog/2020-12-28-09-%E8%AF%AD%E5%8F%A5.html" title="09-语句">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="09-语句"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-09-%E8%AF%AD%E5%8F%A5.html" title="09-语句">09-语句</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T09:18:34.000Z" title="发表于 2020-12-28 17:18:34">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC03%E7%AB%A0%E2%80%94%E2%80%94%E8%AF%AD%E8%A8%80%E5%9F%BA%E7%A1%80/">第03章——语言基础</a></span></div><div class="content">if
if (condition) statement1 else statement2 
条件（condition）可以是任何表达式，并且求值结果不一定是布尔值
ECMAScript 会自动调用 Boolean()函数将这个表达式的值转换为布尔值

1234567if (i &gt; 25) &#123; console.log(&quot;Greater than 25.&quot;);&#125; else if (i &lt; 0) &#123; console.log(&quot;Less than 0.&quot;);&#125; else &#123; console.log(&quot;Between 0 and 25, inclusive.&quot;);&#125; 

do-while
后测试循环语句，循环体内的代码至少执行一次

1234let i = 0;do &#123; i += 2;&#125; while (i &lt; 10); 

while
先测试循环语句，即先检测退出条件，再执行循环体内的代码

1234let i = 0;while (i & ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/blog/2020-12-28-08-%E6%93%8D%E4%BD%9C%E7%AC%A6.html" title="08-操作符">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="08-操作符"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-08-%E6%93%8D%E4%BD%9C%E7%AC%A6.html" title="08-操作符">08-操作符</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T09:02:27.000Z" title="发表于 2020-12-28 17:02:27">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC03%E7%AB%A0%E2%80%94%E2%80%94%E8%AF%AD%E8%A8%80%E5%9F%BA%E7%A1%80/">第03章——语言基础</a></span></div><div class="content">一元操作符
只操作一个值的操作符

自增自减（++ | –）
对于字符串，如果是有效的数值形式，则转换为数值再应用改变。变量类型从字符串变成数值
对于字符串，如果不是有效的数值形式，则将变量的值设置为 NaN 。变量类型从字符串变成 数值
对于布尔值，如果是 false，则转换为 0 再应用改变。变量类型从布尔值变成数值
对于布尔值，如果是 true，则转换为 1 再应用改变。变量类型从布尔值变成数值
对于浮点值，加 1 或减 1
如果是对象，则调用其valueOf()方法取得可以操作的值。对得到的值应用上述规则。如果是 NaN，则调用 toString()并再次应用其他规则。变量类型从对象变成数值

123456let a = 1;let b = a++; //===&gt; b = a = 1, a = a + 1 = 2（减同理）let c = 1;let d = ++c;//===&gt; d = c + 1 = 2, c = c + 1 = 2（减同理）

一元加减
一元加由一个加号（+）表示，放在变量前头，对数值没有任何影响
应用到非数值，则会执行与使用 Number()  ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/blog/2020-12-28-07-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B.html" title="07-数据类型">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="07-数据类型"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-07-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B.html" title="07-数据类型">07-数据类型</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T08:28:37.000Z" title="发表于 2020-12-28 16:28:37">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC03%E7%AB%A0%E2%80%94%E2%80%94%E8%AF%AD%E8%A8%80%E5%9F%BA%E7%A1%80/">第03章——语言基础</a></span></div><div class="content">简单数据类型
Undefined
Null
Boolean
Number
String
Symbol(ES6 新增)

Undefined
单值 undefined
已声明未初始化，或者变量提升
无论是声明还是未声明，typeof 返回的都是字符串&quot;undefined&quot;

1typeof undefined === &#x27;undefined&#x27;


一般来说，永远不用显式地给某个变量设置undefined值。字面值undefined 主要用于比较，而且在 ES3 之前是不存在的。增加这个特殊值的目的就是为了正式明确空对象指针（null）和未初始化变量的区别


即使未初始化的变量会被自动赋予 undefined 值，但我们仍然建议在声明变量的同时进行初始化。这样，当 typeof 返回&quot;undefined&quot;时，你就会知道那是因为给定的变量尚未声明，而不是声明了但未初始化

Null
单值 null
逻辑上讲，null值表示一个空对象指针
undefined派生自null，undefined == null

1typeof null ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/blog/2020-12-28-06-%E5%8F%98%E9%87%8F%E5%A3%B0%E6%98%8E.html" title="06-变量声明">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="06-变量声明"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-06-%E5%8F%98%E9%87%8F%E5%A3%B0%E6%98%8E.html" title="06-变量声明">06-变量声明</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T08:26:48.000Z" title="发表于 2020-12-28 16:26:48">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC03%E7%AB%A0%E2%80%94%E2%80%94%E8%AF%AD%E8%A8%80%E5%9F%BA%E7%A1%80/">第03章——语言基础</a></span></div><div class="content">var
最初定义变量的方法
不初始化会保存为 undefined
使用var定义的变量会成为包含它的函数的局部变量，存在作用域变量提升（只有函数能创建局部作用域）
不使用var而直接赋值的变量会成为全局变量（严格模式抛出 ReferenceError）
一个声明语句可以声明多个变量，以逗号分隔
严格模式不能定义名为evel和arguments的变量
多次声明同一变量也不会报错（变量声明提升，重复声明被合并）
全局声明会成为window的属性
for循环中的变量会泄露到循环体外部

let
大体同var
具有块级作用域，不存在变量提升
同一块级作用域内不能重复声明，会抛出SyntaxError
暂时性死区
全局声明不会成为window的属性
for循环中的变量不会泄露到循环体外部

暂时性死区
声明变量之前引用该变量会抛出ReferenceError

const
基本同let
声明的同时必须初始化
不允许修改指向变量的引用（属性修改不受影响）

推荐使用顺序
const &gt; let
不推荐使用var

</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/blog/2020-12-28-05-%E8%AF%AD%E6%B3%95.html" title="05-语法">     <img class="post_bg" src="/blog/img/hbs.png" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="05-语法"></a></div><div class="recent-post-info"><a class="article-title" href="/blog/2020-12-28-05-%E8%AF%AD%E6%B3%95.html" title="05-语法">05-语法</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2020-12-28T08:24:02.000Z" title="发表于 2020-12-28 16:24:02">2020-12-28</time></span><span class="article-meta"><span class="article-meta__separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right"></i><a class="article-meta__categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC03%E7%AB%A0%E2%80%94%E2%80%94%E8%AF%AD%E8%A8%80%E5%9F%BA%E7%A1%80/">第03章——语言基础</a></span></div><div class="content">区分大小写
无论是变量、函数名还是操作符，全部区分大小写

合法标识符
第一个字符必须是一个字母、下划线或者美元符号
其余的字符可以是数字、字母、下划线、美元符号
推荐使用小驼峰
关键字、保留字、true、false、null 不能作为标识符

注释
单行注释 //
多行注释/*  */
shell 脚本开头的注释 #!/usr/bin/env node

严格模式
ES5 中新增的概念
在脚本或者函数内部开头加入 &quot;use strict&quot;;
不破坏 ES3 语法，会影响执行结果

语句
推荐添加句尾分号，不添加也不会报错
代码块 &#123;&#125; 

关键字12345678910111213// ES3break		do		instanceof		typeofcase		else		new			varcatch		finally		return			voidcontinue	for		switch			whilefunction	this		with			defaultif		throw		delete			intry// ES5debugger// ES ...</div></div></div><nav id="pagination"><div class="pagination"><a class="extend prev" rel="prev" href="/blog/page/11/#content-inner"><i class="fas fa-chevron-left fa-fw"></i></a><a class="page-number" href="/blog/">1</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/11/#content-inner">11</a><span class="page-number current">12</span><a class="page-number" href="/blog/page/13/#content-inner">13</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/16/#content-inner">16</a><a class="extend next" rel="next" href="/blog/page/13/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/blog/img/lufei_siwangningshi.jpg" onerror="this.onerror=null;this.src='/blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">BluesYoung-web</div><div class="author-info__description">一枚不善言辞的技术宅</div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">153</div></a></div><div class="card-info-data-item"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">54</div></a></div><div class="card-info-data-item"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">48</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/BluesYoung-web"><i class="fab fa-gitee"></i><span>点个小星星吧</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/BluesYoung-web" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:15171255945@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-24-%E7%A7%BB%E5%8A%A8%E7%AB%AF%E8%BD%AF%E9%94%AE%E7%9B%98%E5%AF%BC%E8%87%B4%E5%B8%83%E5%B1%80%E9%94%99%E4%B9%B1.html" title="移动端软键盘导致布局错乱"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="移动端软键盘导致布局错乱"/></a><div class="content"><a class="title" href="/blog/2021-08-24-%E7%A7%BB%E5%8A%A8%E7%AB%AF%E8%BD%AF%E9%94%AE%E7%9B%98%E5%AF%BC%E8%87%B4%E5%B8%83%E5%B1%80%E9%94%99%E4%B9%B1.html" title="移动端软键盘导致布局错乱">移动端软键盘导致布局错乱</a><time datetime="2021-08-24T10:01:20.000Z" title="发表于 2021-08-24 18:01:20">2021-08-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-16-Linux%E5%AE%89%E8%A3%85you-get.html" title="Linux安装you-get"><img src="/blog/img/shumeipai_cover.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="Linux安装you-get"/></a><div class="content"><a class="title" href="/blog/2021-08-16-Linux%E5%AE%89%E8%A3%85you-get.html" title="Linux安装you-get">Linux安装you-get</a><time datetime="2021-08-16T08:07:31.000Z" title="发表于 2021-08-16 16:07:31">2021-08-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-16-git%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E6%8F%90%E4%BA%A4.html" title="git删除远程仓库的提交"><img src="/blog/img/skill.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="git删除远程仓库的提交"/></a><div class="content"><a class="title" href="/blog/2021-08-16-git%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E6%8F%90%E4%BA%A4.html" title="git删除远程仓库的提交">git删除远程仓库的提交</a><time datetime="2021-08-16T07:52:02.000Z" title="发表于 2021-08-16 15:52:02">2021-08-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-13-%E5%B0%86pad%E6%89%A9%E5%B1%95%E4%B8%BA%E7%94%B5%E8%84%91%E7%9A%84%E5%89%AF%E5%B1%8F.html" title="将pad扩展为电脑的副屏"><img src="/blog/img/skill.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="将pad扩展为电脑的副屏"/></a><div class="content"><a class="title" href="/blog/2021-08-13-%E5%B0%86pad%E6%89%A9%E5%B1%95%E4%B8%BA%E7%94%B5%E8%84%91%E7%9A%84%E5%89%AF%E5%B1%8F.html" title="将pad扩展为电脑的副屏">将pad扩展为电脑的副屏</a><time datetime="2021-08-13T11:44:04.000Z" title="发表于 2021-08-13 19:44:04">2021-08-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-11-Linux%E5%90%AF%E7%94%A8SSH%E6%9C%8D%E5%8A%A1.html" title="Linux启用SSH服务"><img src="/blog/img/shumeipai_cover.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="Linux启用SSH服务"/></a><div class="content"><a class="title" href="/blog/2021-08-11-Linux%E5%90%AF%E7%94%A8SSH%E6%9C%8D%E5%8A%A1.html" title="Linux启用SSH服务">Linux启用SSH服务</a><time datetime="2021-08-11T10:50:04.000Z" title="发表于 2021-08-11 18:50:04">2021-08-11</time></div></div></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>分类</span>
            <a class="card-more-btn" href="/blog/categories/" title="查看更多">
    <i class="fas fa-angle-right"></i></a>
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/blog/categories/Vue/"><span class="card-category-list-name">Vue</span><span class="card-category-list-count">5</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/blog/categories/nginx/"><span class="card-category-list-name">nginx</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/blog/categories/node/"><span class="card-category-list-name">node</span><span class="card-category-list-count">5</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/blog/categories/%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/"><span class="card-category-list-name">使用教程</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/blog/categories/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/"><span class="card-category-list-name">奇技淫巧</span><span class="card-category-list-count">2</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/"><span class="card-category-list-name">学习笔记</span><span class="card-category-list-count">95</span></a><ul class="card-category-list child"><li class="card-category-list-item "><a class="card-category-list-link" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/CSS/"><span class="card-category-list-name">CSS</span><span class="card-category-list-count">1</span></a><ul class="card-category-list child"><li class="card-category-list-item "><a class="card-category-list-link" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/CSS/Flex%E5%B8%83%E5%B1%80/"><span class="card-category-list-name">Flex布局</span><span class="card-category-list-count">1</span></a></li></ul></li></ul></li>
            </ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>标签</span></div><div class="card-tag-cloud"><a href="/blog/tags/JavaScript/" style="font-size: 1.45em; color: rgb(106, 40, 41)">JavaScript</a><a href="/blog/tags/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E7%AC%AC%E5%9B%9B%E7%89%88/" style="font-size: 1.42em; color: rgb(16, 45, 164)">JavaScript高级程序设计第四版</a><a href="/blog/tags/%E5%B7%A5%E5%85%B7/" style="font-size: 1.17em; color: rgb(192, 44, 109)">工具</a><a href="/blog/tags/CSS3/" style="font-size: 1.2em; color: rgb(7, 31, 84)">CSS3</a><a href="/blog/tags/MySQL/" style="font-size: 1.17em; color: rgb(129, 16, 126)">MySQL</a><a href="/blog/tags/MariaDB/" style="font-size: 1.15em; color: rgb(174, 76, 116)">MariaDB</a><a href="/blog/tags/%E6%A0%91%E8%8E%93%E6%B4%BE/" style="font-size: 1.4em; color: rgb(24, 10, 64)">树莓派</a><a href="/blog/tags/Docker/" style="font-size: 1.27em; color: rgb(150, 187, 164)">Docker</a><a href="/blog/tags/Linux/" style="font-size: 1.32em; color: rgb(147, 0, 147)">Linux</a><a href="/blog/tags/%E5%AE%B9%E5%99%A8/" style="font-size: 1.17em; color: rgb(86, 58, 11)">容器</a><a href="/blog/tags/Node/" style="font-size: 1.2em; color: rgb(96, 4, 136)">Node</a><a href="/blog/tags/CSS/" style="font-size: 1.15em; color: rgb(90, 191, 83)">CSS</a><a href="/blog/tags/linux/" style="font-size: 1.35em; color: rgb(198, 27, 154)">linux</a><a href="/blog/tags/VSCode/" style="font-size: 1.17em; color: rgb(135, 197, 1)">VSCode</a><a href="/blog/tags/TS/" style="font-size: 1.15em; color: rgb(182, 180, 133)">TS</a><a href="/blog/tags/JS/" style="font-size: 1.15em; color: rgb(134, 169, 69)">JS</a><a href="/blog/tags/TweenJS/" style="font-size: 1.15em; color: rgb(25, 63, 142)">TweenJS</a><a href="/blog/tags/Vue3/" style="font-size: 1.25em; color: rgb(51, 124, 12)">Vue3</a><a href="/blog/tags/Vue/" style="font-size: 1.38em; color: rgb(87, 107, 58)">Vue</a><a href="/blog/tags/%E8%AF%AD%E6%B3%95%E7%B3%96/" style="font-size: 1.17em; color: rgb(161, 9, 69)">语法糖</a><a href="/blog/tags/Vite/" style="font-size: 1.17em; color: rgb(61, 169, 173)">Vite</a><a href="/blog/tags/%E6%8A%80%E5%B7%A7/" style="font-size: 1.3em; color: rgb(115, 196, 170)">技巧</a><a href="/blog/tags/terminal/" style="font-size: 1.15em; color: rgb(114, 98, 47)">terminal</a><a href="/blog/tags/Element-Plus/" style="font-size: 1.15em; color: rgb(18, 174, 149)">Element-Plus</a><a href="/blog/tags/%E6%89%93%E5%8C%85/" style="font-size: 1.15em; color: rgb(79, 178, 91)">打包</a><a href="/blog/tags/Git/" style="font-size: 1.15em; color: rgb(44, 194, 88)">Git</a><a href="/blog/tags/gitmoji/" style="font-size: 1.15em; color: rgb(142, 181, 68)">gitmoji</a><a href="/blog/tags/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/" style="font-size: 1.17em; color: rgb(160, 86, 36)">奇技淫巧</a><a href="/blog/tags/nginx/" style="font-size: 1.2em; color: rgb(130, 170, 168)">nginx</a><a href="/blog/tags/vite/" style="font-size: 1.22em; color: rgb(191, 56, 157)">vite</a><a href="/blog/tags/vue/" style="font-size: 1.22em; color: rgb(60, 89, 14)">vue</a><a href="/blog/tags/node/" style="font-size: 1.2em; color: rgb(25, 129, 194)">node</a><a href="/blog/tags/nvm/" style="font-size: 1.15em; color: rgb(117, 91, 161)">nvm</a><a href="/blog/tags/npm/" style="font-size: 1.17em; color: rgb(152, 137, 178)">npm</a><a href="/blog/tags/yarn/" style="font-size: 1.17em; color: rgb(18, 106, 0)">yarn</a><a href="/blog/tags/TypeORM/" style="font-size: 1.17em; color: rgb(10, 142, 3)">TypeORM</a><a href="/blog/tags/TypeScript/" style="font-size: 1.17em; color: rgb(8, 100, 166)">TypeScript</a><a href="/blog/tags/%E7%A7%BB%E5%8A%A8%E7%AB%AF/" style="font-size: 1.15em; color: rgb(181, 77, 121)">移动端</a><a href="/blog/tags/%E5%85%BC%E5%AE%B9/" style="font-size: 1.15em; color: rgb(124, 24, 74)">兼容</a><a href="/blog/tags/%E7%BB%84%E4%BB%B6/" style="font-size: 1.15em; color: rgb(87, 103, 164)">组件</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span><a class="card-more-btn" href="/blog/archives/" title="查看更多">
    <i class="fas fa-angle-right"></i></a></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/blog/archives/2021/08/"><span class="card-archive-list-date">八月 2021</span><span class="card-archive-list-count">10</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/blog/archives/2021/07/"><span class="card-archive-list-date">七月 2021</span><span class="card-archive-list-count">15</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/blog/archives/2021/06/"><span class="card-archive-list-date">六月 2021</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/blog/archives/2021/05/"><span class="card-archive-list-date">五月 2021</span><span class="card-archive-list-count">2</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/blog/archives/2021/04/"><span class="card-archive-list-date">四月 2021</span><span class="card-archive-list-count">5</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/blog/archives/2021/03/"><span class="card-archive-list-date">三月 2021</span><span class="card-archive-list-count">7</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/blog/archives/2021/02/"><span class="card-archive-list-date">二月 2021</span><span class="card-archive-list-count">15</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/blog/archives/2021/01/"><span class="card-archive-list-date">一月 2021</span><span class="card-archive-list-count">49</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">153</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2021-03-05T16:00:00.000Z"></div></div><div class="webinfo-item"><div class="item-name">本站总字数 :</div><div class="item-count">114.8k</div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2021-08-29T11:40:08.789Z"></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By BluesYoung-web</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/blog/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function subtitleType () {
  fetch('https://v1.hitokoto.cn')
    .then(response => response.json())
    .then(data => {
      if (true) {
        const from = '出自 ' + data.from
        const sub = []
        sub.unshift(data.hitokoto, from)
        window.typed = new Typed('#subtitle', {
          strings: sub,
          startDelay: 300,
          typeSpeed: 150,
          loop: true,
          backSpeed: 50,
        })
      } else {
        document.getElementById('subtitle').innerHTML = data.hitokoto
      }
    })
}

if (true) {
  if (typeof Typed === 'function') {
    subtitleType()
  } else {
    getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
  }
} else {
  subtitleType()
}
</script><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script></div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script> <script src="/blog/js/xkTool.js"></script> <script src="/blog/js/mySelf.js"></script><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script></div></body></html>